home *** CD-ROM | disk | FTP | other *** search
- /*===================
-
- Utility routines.
-
- © B.Raoult 92
-
- ====================*/
- #include "tools.h"
-
- #ifndef __TEXTUTILS__
- # include <TextUtils.h>
- #endif
-
- /*
- Returns the rectangle of a dialog item
- */
-
- Rect GetItemR(DialogPtr dialog, short itemno)
- {
- Rect box;
- short type;
- Handle item;
-
- GetDItem(dialog,itemno,&type,&item,&box);
- return box;
- }
-
- /*
- Returns the handle of a dialog item
- */
-
- Handle GetItemH(DialogPtr dialog, short itemno)
- {
- Rect box;
- short type;
- Handle item;
-
- GetDItem(dialog,itemno,&type,&item,&box);
- return item;
- }
-
- /*
- Sets a checkbox
- */
-
- void SetCheck(DialogPtr dialog,short itemno,Boolean on_off)
- {
- SetCtlValue((ControlHandle) GetItemH(dialog,itemno),on_off);
- }
-
- /*
- Get the value of a checkbox
- */
-
- Boolean GetCheck(DialogPtr dialog, short itemno)
- {
- return GetCtlValue((ControlHandle) GetItemH(dialog,itemno));
- }
-
- /*
- Toggle a checkbox, returns the new status
- */
-
- Boolean ClickCheck(DialogPtr dialog, short itemno)
- {
- ControlHandle item = (ControlHandle) GetItemH(dialog,itemno);
- SetCtlValue(item,1-GetCtlValue(item));
- return GetCtlValue(item);
- }
-
- /*
- Put a long integer into an edittext.
- */
-
-
- void Long2Dialog(DialogPtr dialog, short itemno, long value)
- {
- Str255 buf;
-
- NumToString(value,buf);
- SetIText(GetItemH(dialog,itemno),buf);
-
- }
-
- /*
- Get a long integer from an edittext.
- */
-
-
- long Dialog2Long(DialogPtr dialog, short itemno)
- {
- Str255 buf;
- long value;
-
- GetIText(GetItemH(dialog,itemno),buf);
- StringToNum(buf,&value);
- return value;
-
- }
-
- /*
- Checks if color quickdraw is here. I know, I should use Gestalt...
- */
-
-
- Boolean HasColor(void)
- {
- SysEnvRec s;
- if(SysEnvirons(1,&s) == noErr) return s.hasColorQD;
- return false;
- }
-